package org.example.music_sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.music_sys.entity.Admin;
import org.example.music_sys.mapper.AdminMapper;
import org.example.music_sys.service.AdminService;
import org.springframework.stereotype.Service;

@Service  //注解当前类为被Spring容器管理的组件（业务层组件：javabean）
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    @Override
    public boolean add(Admin admin) {
        //查询是否存在重复的管理员
        //创建查询条件包装器
        QueryWrapper<Admin> query = Wrappers.query(Admin.class);
        query.eq("username",admin.getUsername());
        Admin a = getOne(query);
        if(a != null){
            return false;
        }
        return  save(admin);
    }

    @Override
    public boolean login(String usernamr, String password) {
        return false;
    }
}
